// let baseUrl = 'http://localhost:9999/manners';
let baseUrl = 'https://longyugou.top/manners';

export const requestData = (data) => {
	// console.log(data);
	let head = {};
	if(data.method.toUpperCase() === "POST"){
		head = {
			'content-type': "application/x-www-form-urlencoded"
		}
	} else {
		head = {
			 'content-type': "application/json"
		 }
	}
	return new Promise((resolve, reject) => {
		uni.request({
			header: head,
			url: baseUrl + data.url,
			method: data.method || 'POST',
			data: data.data || {},
			success: (res) => {
				resolve(res)
				if(!!res.data.message){
					return uni.showToast({
						title: res.data.message || '加载成功！'
					})
				}
				

			},
			fail: (err) => {
				reject(err)
			}

		})
	})
}
